package com.lagou.mr.homework;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class wordOrderReducer extends Reducer<LongWritable, NullWritable, IntWritable, LongWritable> {
    //创建IntWritable类型用于接收计数数字
    IntWritable count = new IntWritable();
    int num=0;
    @Override
    protected void reduce(LongWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        //设置计数初始值，作为输出key存在


        //每有一行数据，num就加一
        for (NullWritable value : values) {

            num+=1;
            count.set(num);
            context.write(count,key);

        }


    }
}
